package com.wx.exam.service.Impl;

import com.wx.exam.dao.DynamicMapper;
import com.wx.exam.pojo.Dynamic;
import com.wx.exam.pojo.User;
import com.wx.exam.pojo.User_Dynamic;
import com.wx.exam.service.DynamicService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author ychiha
 * @Date 2021/11/26 10:20
 * @Version 1.0
 */
@Service
public class DynamicServiceImpl implements DynamicService {

    @Autowired
    private DynamicMapper dao;

    /**
     * 添加动态
     * @param dynamic 动态对象
     * @return
     */
    @Override
    public Boolean addDynamic(Dynamic dynamic) {

        if(dynamic.getJpgList()!=null){
            System.out.println("before===============================================>"+dynamic);
            String imgList = dynamic.getJpgList();
            dynamic.setImgList(imgList);
            System.out.println("after====================================================>"+dynamic);
        }

        int i = dao.addDynamic(dynamic);
        System.out.println(i);
        if(i>0){
            return true;
        }else{
            return false;
        }
    }

    /**
     * 获取最大的Did
     * @return
     */
    public Integer getMaxDid(){
        return dao.getMaxDid();
    }

    /**
     * 添加用户id——动态id
     * @param user_dynamic
     * @return
     */
    @Override
    public Boolean addU_D(User_Dynamic user_dynamic) {
        int i = dao.addU_D(user_dynamic);
        if(i>0){
            return true;
        }else{
            return false;
        }
    }

    /**
     * 通过Uid 查询用户所有的动态Did
     * @param user
     * @return
     */
    @Override
    public List<Integer> getDynamicByUid(User user){
        return dao.getDynamicByUid(user);
    }

}
